﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LIMS.Entities;
using LIMS.Shared;

namespace LIMS.Windows
{
    public partial class ManagerPopUp : Form
    {
        public User oUser = new User();
        private int iManagerId = 0;
        private string sDepartmentID = string.Empty;

        public int ManagerId
        {
            get { return iManagerId; }
            set { iManagerId = value; }
        }

        public string DepartmentID

        {
            get { return sDepartmentID; }
            set { sDepartmentID = value; }
        }
        public ManagerPopUp(User p_oUser)
        {
            InitializeComponent();
            oUser = p_oUser;
        }

        private void ManagerPopUp_Load(object sender, EventArgs e)
        {
            ///get dept based on HOD 
            ///
            ///load Supervisor on basis of dept
            ///

            cmbDept.DataSource = SharedResource.GetHODDept(oUser, true); ;
            cmbDept.DisplayMember = "Name";
            cmbDept.ValueMember = "Id";
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            ManagerId = Convert.ToInt32(cmbManager.SelectedValue);
            DepartmentID = Convert.ToString(cmbDept.SelectedValue);
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cmbDept_SelectionChangeCommitted(object sender, EventArgs e)
        {
            ///get Manager
            cmbManager.DataSource = null;
            cmbManager.DataSource = SharedResource.GetManager(Convert.ToString( cmbDept.SelectedValue),2, true);
            cmbManager.DisplayMember = "UserName";
            cmbManager.ValueMember = "Id";
        }
    }
}
